
//
//  RepayDidViewController.m
//  OneCreditTreasure
//
//  Created by iOS Grouper on 16/8/30.
//
//

#import "RepayDidViewController.h"
#import "YHYcommenTableViewCell.h"
#import "PayStyleTableViewCell.h"
@interface RepayDidViewController ()<UITableViewDelegate,UITableViewDataSource>
{
    UITableView *myTableView;
    NSMutableDictionary *selectButtonDic;
    UIButton *applyButton;
}
@property (nonatomic, strong)NSMutableArray *titleArray;

@end

@implementation RepayDidViewController
- (void)viewWillAppear:(BOOL)animated{
    self.tabBarController.tabBar.hidden = YES;
}
- (void)viewWillDisappear:(BOOL)animated{
    self.tabBarController.tabBar.hidden = NO;
}



- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"还款";
    _titleArray = [NSMutableArray arrayWithObjects:@"本月还款",@"期数",@"总期数",@"贷款额度(元)",@"还款方式",@"月利率",@"总利息(元)", nil];
    selectButtonDic = [NSMutableDictionary dictionary];
    self.view.backgroundColor = LV;
    myTableView = [UITableView new];
    [self.view addSubview:myTableView];
    myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [myTableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.mas_equalTo(self.view);
        make.width.mas_equalTo(kScreenW);
        make.height.mas_equalTo(kScreenH);
        
    }];
    myTableView.delegate = self;
    myTableView.dataSource = self;
    [myTableView registerClass:[YHYcommenTableViewCell class] forCellReuseIdentifier:@"YHYcommenTableViewCell"];
    [myTableView registerClass:[PayStyleTableViewCell class] forCellReuseIdentifier:@"PayStyleTableViewCell"];
    [myTableView reloadData];

    
    
    applyButton = [UIButton new];
    [self.view addSubview:applyButton];
    [applyButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(self.view);
        make.height.mas_equalTo(50 * AUTO_HEIGHT);
        make.left.mas_equalTo(0);
        make.centerXWithinMargins.mas_equalTo(self.view);
        
    }];
    applyButton.backgroundColor = [UIColor whiteColor];
    applyButton.titleLabel.font = [UIFont fontWithName:ZIXING size:14 ];
    [applyButton setTitleColor:HS forState:UIControlStateNormal];
    [applyButton setTitle:@"去支付" forState:UIControlStateNormal];
    
    
    UIView *line = [UIView new];
    [applyButton addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(applyButton.mas_top);
        make.height.mas_equalTo(0.4);
        make.width.mas_equalTo(kScreenW);
        
        
    }];
    line.backgroundColor = HS;
    
    

    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section == 0) {
        return 2;
    }
    if (section == 1) {
        return 5;
    }
    else{
      return 4;
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
     YHYcommenTableViewCell *cell =[tableView dequeueReusableCellWithIdentifier:@"YHYcommenTableViewCell"];
    if (indexPath.section == 0) {
     cell.leftTitleL.text = _titleArray[indexPath.row];
    }
    if (indexPath.section == 1) {
        cell.leftTitleL.text = _titleArray[ indexPath.section+indexPath.row + 1];
    }
    if (indexPath.section == 2 && indexPath.row == 0) {
        cell.leftTitleL.text = @"还款方式";
        cell.backgroundColor = ZITI;
        cell.alpha = 0.1;
    }
    
    if (indexPath.section == 2 && indexPath.row > 0) {
        PayStyleTableViewCell *ce = [tableView dequeueReusableCellWithIdentifier:@"PayStyleTableViewCell"];
       
        return ce;
    }

    return cell;
    
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 2 && indexPath.row>0) {
        
    PayStyleTableViewCell *cell = (PayStyleTableViewCell *)[myTableView cellForRowAtIndexPath:indexPath];
    }
        }

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 10 * AUTO_HEIGHT;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 3;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 2 && indexPath.row > 0) {
        return 60 * AUTO_HEIGHT;
    }
    else{
        return myTableView.rowHeight;
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
